#include "stm32f10x.h"                  // Device header
#include "Delay.h"

#include "LED.h"
#include "Key.h"
#include "OLED.h"
#include "MyRTC.h"

int main(void)
{
	// 初始化
	OLED_Init();
	
	MyRTC_Init();
	
	OLED_ShowString(1, 1, "Date:XXXX-XX-XX");
	OLED_ShowString(2, 1, "Time:XX:XX:XX");
	OLED_ShowString(3, 1, "CNT:");
	OLED_ShowString(4, 1, "DIV:");
	
	while(1)
	{
		// 读取时间到数组
		MyRTC_ReadTime();
		
		// OLED 显示时间
		OLED_ShowNum(1, 6, MyRTC_Time[0], 4);
		OLED_ShowNum(1, 11, MyRTC_Time[1], 2);
		OLED_ShowNum(1, 14, MyRTC_Time[2], 2);
		OLED_ShowNum(2, 6, MyRTC_Time[3], 2);
		OLED_ShowNum(2, 9, MyRTC_Time[4], 2);
		OLED_ShowNum(2, 12, MyRTC_Time[5], 2);
		
		// OLED 显示 CNT
		OLED_ShowNum(3, 5, RTC_GetCounter() + 28800, 10);
		
		// OLED 显示 DIV
		OLED_ShowNum(4, 5, RTC_GetDivider(), 10);
	}
}